export const projectInfoColumns = [
  {
    title: '序号',
    width: 80,
    dataIndex: 'index',
    customRender() {
      return arguments[2] + 1
    }
  }, {
    title: '项目名称',
    dataIndex: 'projectName',
    width: "350px",
    ellipsis: true
  }, {
    title: '工程承包模式',
    dataIndex: 'contractModelName',
  }, {
    title: '项目类型',
    dataIndex: 'projectTypeName',
  }, {
    title: '项目业态',
    dataIndex: 'projectFormats',
  }, {
    title: '重要程度',
    dataIndex: 'projectImportanceName',
  }, {
    title: '在建建筑面积/万m²',
    dataIndex: 'totalArea',
  }, {
    title: '在施工程里程km',
    dataIndex: 'totalKm',
  }, {
    title: '合同额（万元）',
    dataIndex: 'contractAmount',
  }, {
    title: '形象进度',
    dataIndex: 'progress',
  }, {
    title: '备案项目经理',
    dataIndex: 'projectRecordManager',
  }, {
    title: '实际项目经理',
    dataIndex: 'name',
  }, {
    title: '实际项目经理持证',
    dataIndex: 'workRigs',
  }, {
    title: '实际项目经理年龄',
    dataIndex: 'age',
  }, {
    title: '实际项目经理工作年限',
    dataIndex: 'workNum',
  }, {
    title: '实际项目经理任项目经理年限',
    dataIndex: 'managerNum',
  }, {
    title: '项目人员总数量',
    dataIndex: 'projectTotal',
  }, {
    title: '配置人数情况',
    dataIndex: 'allocatTotal',
  },

]

// 格式化文本
export const formatText = function(){
  if((arguments[1].auditStatusStr && arguments[1].auditStatusStr !== '审核通过') || (!arguments[0] && arguments[0] != 0)){
    return '-'
  } 
  return arguments[0]
}
// 关键绩效指标完成情况
export const targetComplete = [
  {
    title: '序号',
    width: 80,
    dataIndex: 'index',
    customRender() {
      return arguments[2] + 1
    }
  }, {
    title: '项目名称',
    dataIndex: 'projectName',
    width: "150px",
    ellipsis: true
  }, {
    title: '是否重点项目',
    dataIndex: 'keyProgram',
    width: "70px",  
    customRender() {
      return arguments[0] ? arguments[0] : '-'
    }
  }, {
    title: '工期滞后天数',
    dataIndex: 'lagNum',
    customRender() {
      return formatText(...arguments)
    }
  }, {
    title: '业主确认工期天数',
    dataIndex: 'confirmNum',
    customRender() {
      return formatText(...arguments)
    }
  }, {
    title: '工期履约率（%）',
    dataIndex: 'periodRate',
    customRender() {
      return formatText(...arguments)
    }
  }, {
    title: '合同外工期确认率',
    dataIndex: 'contractOtherRate',
    customRender() {
      return formatText(...arguments)
    }
  }, {
    title: '合同额（亿元）',
    dataIndex: 'contractAmount',
    customRender() {
      return formatText(...arguments)
    }
  }, {
    title: '开工累计确认产值（亿元）',
    dataIndex: 'startAllOutputTotal',
    customRender() {
      return formatText(...arguments)
    }
  }, {
    title: '开工累计产值完成率',
    dataIndex: 'startAllOutputRate',
    customRender() {
      return formatText(...arguments)
    }
  }, {
    title: '年度累计计划产值（万元）',
    dataIndex: 'yearOutputPlanTotal',
    customRender() {
      return formatText(...arguments)
    }
  }, {
    title: '年度累计确权产值（万元）',
    dataIndex: 'yearOutputConfirmTotal',
    customRender() {
      return formatText(...arguments)
    }
  }, {
    title: '产值完成率',
    dataIndex: 'completionRate',
    customRender() {
      return formatText(...arguments)
    }
  }, {
    title: '人均产值(万元)',
    dataIndex: 'completionPre',
    customRender() {
      return formatText(...arguments)
    }
  }, {
    title: '一级节点按时完成率',
    dataIndex: 'firstNodeRate',
    customRender() {
      return formatText(...arguments)
    }
  }, {
    title: '二级节点按时完成率',
    dataIndex: 'secondNodeRate',
    customRender() {
      return formatText(...arguments)
    }
  }, {
    title: '三级节点按时完成率',
    dataIndex: 'thirdNodeRate',
    customRender() {
      return formatText(...arguments)
    }
  }, {
    title: '节点按时完成率平均值',
    dataIndex: 'nodeAvgRate',
    customRender() {
      return formatText(...arguments)
    }
  }, {
    title: '实名制出勤率',
    dataIndex: 'realnameRate',
    customRender() {
      return formatText(...arguments)
    }
  }, {
    title: '顾客满意度',
    dataIndex: 'satisfaction',
    customRender() {
      return formatText(...arguments)
    }
  }, {
    title: '投诉',
    dataIndex: 'complaint',
    customRender() {
      return formatText(...arguments)
    }
  }, {
    title: '综合得分',
    dataIndex: 'totalScore',
    customRender() {
      return formatText(...arguments)
    }
  }, {
    title: '综合排名',
    dataIndex: 'totalRank',
    customRender() {
      return formatText(...arguments)
    }
  }, {
    title: '是否参加排名',
    dataIndex: 'haveRank',
    scopedSlots: { customRender: 'haveRank' }
  },
  {
    title: '状态',
    dataIndex: 'auditStatusStr',
  },
  {
    title: '操作',
    dataIndex: 'action',
    width: '80px',
    fixed: 'right',
    scopedSlots: { customRender: 'action' }
  }
]
// 风险情况统计
export let riskStatisticsColumns = [
  {
    title: '序号',
    width: 65,
    dataIndex: 'index',
    customRender() {
      return arguments[2] + 1
    }
  }, {
    title: '项目名称',
    dataIndex: 'projectName',
    width: "150px",
    ellipsis: true
  }, {
    title: '是否重点项目',
    dataIndex: 'keyProgram',
    width: "70px",
  },
  {
    title: 'X-1月滞后天数',
    dataIndex: 'lastLagNum',
    width: "70px",
  }, {
    title: 'X-X月滞后天数',
    dataIndex: 'nowLagNum',
    width: "70px",
  }, {
    title: 'X月工期履约率',
    dataIndex: 'periodRate',
    width: "70px",
  },
  {
    title: '滞后原因分析',
    dataIndex: 'analysis',
    scopedSlots: { customRender: 'analysis' }
  },
  {
    title: '采取措施',
    dataIndex: 'takeSteps',
    scopedSlots: { customRender: 'takeSteps' }
  },

  {
    title: '分公司责任人',
    dataIndex: 'branchCompanyDutyId',
    scopedSlots: { customRender: 'branchCompanyDutyId' }
  },
  {
    title: '项目责任人',
    dataIndex: 'projectDutyId',
    scopedSlots: { customRender: 'projectDutyId' }
  },
  {
    title: '完成时间',
    dataIndex: 'endTime',
    scopedSlots: { customRender: 'endTime' }
  },
  {
    title: '备注',
    dataIndex: 'remarks',
    scopedSlots: { customRender: 'remarks' }
  },
  {
    title: '操作',
    dataIndex: 'action',
    width: "80px",
    // fixed: 'right',
    scopedSlots: { customRender: 'action' }
  }
]
export const importantMattersColumns = [
  {
    title: '序号',
    width: 80,
    dataIndex: 'index',
    customRender() {
      return arguments[2] + 1
    }
  }, {
    title: '项目名称',
    dataIndex: 'projectName',
    width: "350px",
    ellipsis: true
  }, {
    title: '是否重点项目',
    dataIndex: 'keyProgram',
  }, {
    title: '设计问题',
    dataIndex: 'designProblem',
    scopedSlots: { customRender: 'designProblem' }
  }, {
    title: '分包分供问题',
    dataIndex: 'subProblem',
    scopedSlots: { customRender: 'subProblem' }
  }, {
    title: '其他',
    dataIndex: 'other',
    scopedSlots: { customRender: 'other' }
  },
  {
    title: '操作',
    dataIndex: 'action',
    width: "80px",
    // fixed: 'right',
    scopedSlots: { customRender: 'action' }
  }
]
export const complaintsColumns = [
  {
    title: '序号',
    width: 80,
    dataIndex: 'index',
    customRender() {
      return arguments[2] + 1
    }
  }, {
    title: '项目名称',
    dataIndex: 'projectName',
    width: "350px",
    ellipsis: true
  }, {
    title: '是否重点项目',
    dataIndex: 'keyProgram',
  }, {
    title: '投诉内容',
    dataIndex: 'complaint',
    scopedSlots: { customRender: 'complaint' }
  }, {
    title: '操作',
    dataIndex: 'action',
    width: "80px",
    // fixed: 'right',
    scopedSlots: { customRender: 'action' }
  }
]
// 节点、劳动力管控问题
export let controlProblem = [
  {
    title: '序号',
    width: 80,
    dataIndex: 'index',
    customRender() {
      return arguments[2] + 1
    }
  }, {
    title: '项目名称',
    dataIndex: 'projectName',
    width: "350px",
    ellipsis: true
  }, {
    title: '是否重点项目',
    dataIndex: 'keyProgram',
  },
  {
    title: '存在问题说明',
    dataIndex: 'problem',
    scopedSlots: { customRender: 'problem' }
  },
  {
    title: '纠偏措施',
    dataIndex: 'correctiveAction',
    scopedSlots: { customRender: 'correctiveAction' }
  },
  {
    title: '完成时间',
    dataIndex: 'completeTime',
    scopedSlots: { customRender: 'completeTime' }
  },
  {
    title: '备注',
    dataIndex: 'remarks',
    scopedSlots: { customRender: 'remarks' }
  },
  {
    title: '操作',
    dataIndex: 'action',
    width: "8%",
    scopedSlots: { customRender: 'action' }
  }
]
// 分包、分供招采问题
export const miningProblem = [
  {
    title: '序号',
    width: 80,
    dataIndex: 'index',
    customRender() {
      return arguments[2] + 1
    }
  }, {
    title: '项目名称',
    dataIndex: 'projectName',
    width: "350px",
    ellipsis: true
  }, {
    title: '是否重点项目',
    dataIndex: 'keyProgram',
  },
  {
    title: '存在问题说明',
    dataIndex: 'problem',
    scopedSlots: { customRender: 'problem' }
  },
  {
    title: '纠偏措施',
    dataIndex: 'correctiveAction',
    scopedSlots: { customRender: 'correctiveAction' }
  },
  {
    title: '完成时间',
    dataIndex: 'completeTime',
    scopedSlots: { customRender: 'completeTime' }
  },
  {
    title: '备注',
    dataIndex: 'remarks',
    scopedSlots: { customRender: 'remarks' }
  },
  {
    title: '操作',
    dataIndex: 'action',
    width: "8%",
    scopedSlots: { customRender: 'action' }
  }
]

export const designProblems = [
  {
    title: '序号',
    width: 80,
    dataIndex: 'index',
    customRender() {
      return arguments[2] + 1
    }
  }, {
    title: '项目名称',
    dataIndex: 'projectName',
    width: "350px",
    ellipsis: true
  }, {
    title: '是否重点项目',
    dataIndex: 'keyProgram',
  },
  {
    title: '存在问题说明',
    dataIndex: 'problem',
    scopedSlots: { customRender: 'problem' }
  },
  {
    title: '纠偏措施',
    dataIndex: 'correctiveAction',
    scopedSlots: { customRender: 'correctiveAction' }
  },
  {
    title: '完成时间',
    dataIndex: 'completeTime',
    scopedSlots: { customRender: 'completeTime' }
  },
  {
    title: '备注',
    dataIndex: 'remarks',
    scopedSlots: { customRender: 'remarks' }
  },
  {
    title: '操作',
    dataIndex: 'action',
    width: "8%",
    scopedSlots: { customRender: 'action' }
  }
]
export let sinceTheSituationColumns = [
  {
    title: '序号',
    width: 80,
    dataIndex: 'index',
    customRender() {
      return arguments[2] + 1
    }
  }, {
    title: '策划检查负责人',
    dataIndex: 'dutyPersonName',
  }, {
    title: '项目类型',
    dataIndex: 'projectType',
  }, {
    title: '应履职项目',
    ellipsis: true,
    dataIndex: 'projectName',
  }, {
    title: '土建履职情况',
    children: [
      {
        title: '是否履职',
        dataIndex: 'civiHave',
      }, {
        title: '实际检查人',
        dataIndex: 'civiCheckEmpName',
      }
    ]
  }, {
    title: '安装履职情况',
    children: [
      {
        title: '是否履职',
        dataIndex: 'decorateHave',
      }, {
        title: '实际检查人',
        dataIndex: 'decorateCheckEmpName',
      }
    ]
  }, {
    title: '装饰履职情况',
    children: [
      {
        title: '是否履职',
        dataIndex: 'installHave',
      }, {
        title: '实际检查人',
        dataIndex: 'installCheckEmpName',
      }
    ]
  }, {
    title: '备注',
    dataIndex: 'remarks',
    scopedSlots: { customRender: 'remarks' }
  },
]
export let nodeStatisticsColumns = [
  {
    title: '序号',
    width: 80,
    dataIndex: 'index',
    customRender() {
      return arguments[2] + 1
    },
  }, {
    title: '项目名称',
    dataIndex: 'projectName',
    width: "350px",
    ellipsis: true
  }, {
    title: '是否重点项目',
    dataIndex: 'keyProgram',
  }, {
    title: '节点名称',
    dataIndex: 'nodeName',
  }, {
    title: '节点计划完成时间',
    dataIndex: 'palnTime',
  }, {
    title: '完成情况',
    dataIndex: 'situation',
  }, {
    title: '完成时间',
    dataIndex: 'completeTime',
    scopedSlots: { customRender: 'completeTime' }
  }
]

export let nextmonthColumns = [
  {
    title: '序号',
    width: 80,
    dataIndex: 'index',
    customRender() {
      return arguments[2] + 1
    }
  }, {
    title: '项目名称',
    dataIndex: 'projectName',
    width: "350px",
    ellipsis: true
  }, {
    title: '是否重点项目',
    dataIndex: 'keyProgram',
  }, {
    title: '节点名称',
    dataIndex: 'nodeName',
  }, {
    title: '节点计划完成时间',
    dataIndex: 'nodePlanTime',

  },
]

export let nextmonthPlanningColumns = [
  {
    title: '序号',
    width: 80,
    dataIndex: 'index',
    customRender() {
      return arguments[2] + 1
    }
  }, {
    title: '项目名称',
    dataIndex: 'projectName',
    width: "350px",
    ellipsis: true
  }, {
    title: '是否重点项目',
    dataIndex: 'keyProgram',

  },
  {
    title: '下月工作安排内容',
    dataIndex: 'nextMonthWork',
    scopedSlots: { customRender: 'nextMonthWork' }
  }, {
    title: '操作',
    dataIndex: 'action',
    width: "8%",
    scopedSlots: { customRender: 'action' }
  }
]
export function colspan(text, row, index, list = [], key) {
  console.log(text)
  let obj = {
    children: text,
    attrs: {}
  }
  let lastIndex = -1
  let firstIndex = list.findIndex((v) => v[key] === text)
  list.map((m, i) => {
    if (m[key] == text) {
      lastIndex = i
    }
  })
  // 若该行内容和上一行一致，则使其隐藏
  if (index > 0 && list[index - 1][key] == text) {
    obj.attrs.rowSpan = 0
    // 若不是，则往下合并与改行内容一致行的总行数
  } else {
    obj.attrs.rowSpan = lastIndex === firstIndex ? 1 : lastIndex + 1 - firstIndex
  }

  return obj
}
//根据传入key值合并
export function colspanProjectName(text, row, index, list = [], key) {

  let obj = {
    children: text,
    attrs: {}
  }
  let lastIndex = -1
  let firstIndex = list.findIndex((v) => v[key] === row[key])
  list.map((m, i) => {
    if (m[key] == row[key]) {
      lastIndex = i
    }
  })
  // 若该行内容和上一行一致，则使其隐藏
  if (index > 0 && list[index - 1][key] == row[key]) {
    obj.attrs.rowSpan = 0
    // 若不是，则往下合并与改行内容一致行的总行数
  } else {
    obj.attrs.rowSpan = lastIndex === firstIndex ? 1 : lastIndex + 1 - firstIndex
  }

  return obj
}
export function sorter(data1, data2, key, type) {
  const a = data1[key],
    b = data2[key]
  if (a != null && b != null) {
    if (a - b > 0) {
      return 1
    }
    if (a - b < 0) {
      return -1
    }
  }
  if (a == null || b == null) {
    //判断升序降序值为null始终置顶
    if (type == 'ascend') {
      if (a == null) {
        return -1
      }
      if (b == null) {
        return 1
      }
    } else {
      if (a == null) {
        return 1
      }
      if (b == null) {
        return -1
      }
    }

  }
  return 0
}
// 公司/分公司业主确认延期佐证资料
export const supportingInformationFileColumns = [
  {
    title: '序号',
    width: 70,
    align: 'center',
    customRender: (text, record, index) => {
      return index + 1
    }
  },
  {
    title: '分公司',
    dataIndex: 'branchCompanyName',
    width: 300,
    ellipsis: true,
    customRender: (text, row, index) => {
      return {
        children: text,
        attrs: {
          rowSpan: row.branchCompanyNameRowSpan
        }
      }
    }
  },
  {
    title: '项目名称',
    dataIndex: 'name',
    width: 300,
    ellipsis: true,
    customRender: (text, row, index) => {
      return {
        children: text,
        attrs: {
          rowSpan: row.nameRowSpan
        }
      }
    }
  },
  {
    title: '附件名称',
    dataIndex: 'fileName',
    customRender() {
      return arguments[1].fileInfoVO?.fileName
    }
  },
  {
    title: '附件类型',
    dataIndex: 'suffixName',
    customRender: (text, row, index) => {
      return row.fileInfoVO?.suffixName
    }
  },
  {
    title: '操作',
    key: 'action',
    fixed: 'right',
    width: 150,
    scopedSlots: { customRender: 'action' }
  }
]